package com.cesce.batch.cobros.service;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;


import org.springframework.context.annotation.Primary;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;

import com.cesce.batch.cobros.exceptions.FTPException;

@Service
public class FtpRegistroMockImpl implements FtpService {

//	public Resource[] getRegistros() throws FtpRegistroException;
//		String server = "ftp.bls.gov";
//	    String username = "anonymous";
//	    String password = "anonymous@anonymous.com";
//	    String directory ="/pub/time.series/cu/";
//	
//	    Resource[] resources=null;
//	    
//	    try {
//	        FTPClient f=new FTPClient();
//	        f.connect(server);
//	        f.login(username, password);
//	        FTPFile[] files = f.listFiles(directory);
//	        for (int i = 0; i < files.length; i++) {
//	            FTPFile ftpFile = files[i];
//	            System.out.println(ftpFile.getName());
//	        }
//	        System.out.println("total files: " + files.length);
//	    } catch (IOException ex) {
//	        ex.printStackTrace();
//	    }
//	    
//	    return resources;
//	}
	
	private String directoryLocal;
	
	
	public String getDirectoryLocal() {
		return directoryLocal;
	}

	public void setDirectoryLocal(String directoryLocal) {
		this.directoryLocal = directoryLocal;
	}

	
	public void setDirectory(String directory) {
		
	}
	public String getDirectory() {
		return "";
	}
	
/*	public Resource[] getRegistros() throws FTPRegistroException {


    Resource[] resources=new Resource[2];
    
    resources[0]=new FileSystemResource(new File("3680_cobros.csv"));
    resources[1]=new FileSystemResource(new File("33373_cobros.csv"));
    
    return resources;
}*/


	public InputStream getFileByName(String name) throws FTPException {


		
		try {
			return this.getClass().getResourceAsStream(directoryLocal + name);
	        
	    } catch (Throwable e) {
	        throw new FTPException(directoryLocal + name,e);
	    }
	}

	public void setFileWithName(InputStream is, String name)
			throws FTPException {
	}
	

}
